//
// Created by root on 2019/9/26.
//

#ifndef AOA_AOAAUDIO_H
#define AOA_AOAAUDIO_H

#include "headerBase.h"

#include <thread>
#include <mutex>


class AOAaudio {
public:
    explicit AOAaudio(libusb_device *dev);

    bool isEqual(libusb_device *dev);

    int sendKey(const uint8_t *event, uint nSz = 2);

    virtual ~AOAaudio();

    void registerHid();

    void unRegisterHid();

    void writeCache2File();

    friend void isoCallback(struct libusb_transfer *xfer);

private:
    void _startCapAudio();

    void _startCapAudio( uint8_t audioEp, uint16_t audioEpSz) ;
    void _isoCallback(libusb_transfer *pTransfer);

    bool m_bQuit;
    uint8_t m_AudioInterface;
    libusb_device_handle *m_devHdl;
//    std::thread m_thread;
    vector<libusb_transfer *> m_nTransfer;
    FILE *m_fdFile;
    vector<char> m_cache;
    std::mutex m_cacheLock;
};


#endif //AOA_AOAAUDIO_H
